package com.mindbook.vip.gawxchatinfo.utils.crud;

import com.mindbook.vip.gawxchatinfo.exception.crud.CurdException;
import com.mindbook.vip.gawxchatinfo.exception.sql.SqlException;
import com.mindbook.vip.gawxchatinfo.utils.result.Result;
import com.mindbook.vip.gawxchatinfo.utils.result.ResultEnum;
import org.springframework.stereotype.Component;

/**
 * @NAME: wxb
 * @DATE: 2022/5/16
 * @Description 数据库持久化操作的工具类处理
 **/
public class CrudUtils {

    /**
     * 数据进行新增后，进行操作结果校验
     * @param count
     */
    public static void validateAddResult(Integer count){
        if(count==0){
            throw new CurdException(ResultEnum.DATA_INSERT_FAIL);
        }
    }

    public static void validateUpdateResult(Integer count){
        if(count==0){
            throw new CurdException(ResultEnum.DATA_UPDATE_FAIL);
        }
    }

    public static void validateDeleteResult(Integer count){
        if(count==0){
            throw new CurdException(ResultEnum.DATA_DELETE_FAIL);
        }
    }

}
